package org.shj.basic;

import java.io.File;
import java.io.FileOutputStream;

/**
 * @author Shen Huang Jian
 * @date 2019-11-13 19:38
 */
public class WriteFile {

    public static void main(String[] args){
        FileOutputStream os = null;
        try{
            os = new FileOutputStream(new File("d:/test/tbl_cam.sql"));
//            String sql = "INSERT tbl_cam (id, cam_name, cam_code, point_type, area_code, dept_code, `status`, latitude, longitude, camera_type) " +
//                    "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
            String sql = "INSERT tbl_cam (id, cam_name, cam_code) " +
                    "VALUES (%d, '%s', '%s');\n";
            for(int i = 500; i < 1500; i++){
                os.write(String.format(sql, i, "cam_name" + i, "cam_code" + i).getBytes());

            }
            os.flush();

        }catch (Exception e){

        }
        finally {
            try {
                if (os != null) {
                    os.close();
                }
            }catch (Exception e){

            }
        }
    }
}
